package thread.example;

/**
 * Created by simod on 2019/12/21
 */
public class Window extends Thread {
    private String name;

    public Window(String name1) {
        this.name = name1;
    }

    public Window() {
    }

    @Override
    public void run() {
        this.sellTicket();
    }

    private void sellTicket() {
        while (true) {
            System12306 system12306 = System12306.getInstance();
            Ticket ticket = system12306.getTicket();
            if (ticket == null) {
                System.out.println("票已售完");
                break;
            }
            System.out.println(this.name + "=>" + ticket);
        }
    }

    public static void main(String[] args) {
        Window w1 = new Window("1号窗口");
        Window w2 = new Window("2号窗口");
        Window w3 = new Window("3号窗口");
        w1.start();
        w2.start();
        w3.start();
    }
}
